package com.lambkit.component.shiro;

import org.apache.shiro.web.filter.mgt.FilterChainManager;
import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;
import org.apache.shiro.web.servlet.AbstractShiroFilter;

public class LambkitShiroFilter extends AbstractShiroFilter {
	@Override
	public void init() throws Exception {
		System.out.println(getClass().getSimpleName() + " init.......");
		LambkitShiroConfigService shiroConfigService = ShiroManager.me().getShiroConfigService();
		if(shiroConfigService==null) {
			shiroConfigService = new DefaultLambkitShiroConfigService();
		}
		setSecurityManager(shiroConfigService.createSecurityManager());
		
		LambkitShiroFilterFactory factory = shiroConfigService.createShiroFilterFactory();
		FilterChainManager manager = factory.createFilterChainManager();
		
		PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
		chainResolver.setFilterChainManager(manager);
		
		setFilterChainResolver(chainResolver);
	}
}
